package cn.bdqn.service.impl;

import cn.bdqn.mapper.ItripHotelOrderMapper;
import cn.bdqn.pojo.ItripHotelOrder;
import cn.bdqn.service.OrderSearchService;
import cn.bdqn.util.Page;
import cn.bdqn.vo.ItripHotelOrderEx;
import cn.bdqn.vo.ItripHotelOrderSearchVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2018/8/22.
 */
@Service
public class OrderSearchServiceImpl implements OrderSearchService {
    @Resource
    private ItripHotelOrderMapper itripHotelOrderMapper;

    @Override
    public Page getHotelOrderListByPage(String currentPage,String pageSize, ItripHotelOrderEx itripHotelOrderEx) {
        long currentPageNo=0;
        if(currentPage==null||currentPage.trim()==""){
            currentPageNo=1;
        }
        else {
            currentPageNo=Long.valueOf(currentPage);
        }
        long totalRecords = this.getTotalHotelOrderCountByEx(itripHotelOrderEx);
        Page page=new Page(currentPageNo,totalRecords,Long.valueOf(pageSize),itripHotelOrderEx);
        List<ItripHotelOrderSearchVo> orderExList=itripHotelOrderMapper.findHotelOrderListByPage(page);
        page.setRows(orderExList);
        return page;
    }

    @Override
    public Long getTotalHotelOrderCountByEx(ItripHotelOrderEx itripHotelOrderEx) {
        return itripHotelOrderMapper.getTotalHotelOrderCount(itripHotelOrderEx);
    }

    @Override
    public ItripHotelOrder getByPrimaryKey(Long id) {
        return itripHotelOrderMapper.selectByPrimaryKey(id);
    }
}
